package com.estun.backroundManagementService.utils;

import com.alibaba.excel.EasyExcel;
import com.estun.backroundManagementService.domain.excel.DemoData;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class ExcelTest {

    public static void main(String[] args) {
        // 文件路径可以根据实际情况进行修改
        String fileName = "DemoData.xlsx";

        // 准备数据
        List<DemoData> dataList = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            DemoData data = new DemoData();
            data.setString("字符串" + i);
            data.setDate(new Date());
            data.setDoubleData(100.0 * i);
            dataList.add(data);
        }

        // 写入数据到Excel文件
        EasyExcel.write(fileName, DemoData.class).sheet("模板").doWrite(dataList);

        System.out.println("Excel文件已生成: " + fileName);
    }
}
